package com.lvsc.sdaplacefinder.adapter;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

import com.lvsc.sdaplacefinder.models.ImageToUpload;

public class ImageAdapter extends BaseAdapter {

	private List<ImageToUpload> list;
	private Context mContext;

	public ImageAdapter(Context context, List<ImageToUpload> list) {
		this.list = list;
		this.mContext = context;
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ImageView imageView = new ImageView(mContext);
		imageView.setImageBitmap(list.get(position).getImage());
		imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
		imageView.setLayoutParams(new GridView.LayoutParams(130, 130));
		return imageView;
	}

}
